package com.cndym.adapterForMobile;

import com.cndym.adapterForMobile.global.IGlobalOperator;
import com.cndym.exception.ErrCode;
import com.cndym.utils.SpringUtils;
import com.cndym.utils.Utils;

import javax.servlet.http.HttpServletRequest;

/**
 * Description:
 * Author:cndym
 * Time:2013-01-05 10:42
 */
public class GlobalMobileAdapter {
    public static final String JSON = "json";
    public static final String XML = "xml";

    public String execute(String type, String msg, HttpServletRequest request) {
        if (!Utils.isNotEmpty(type)) {
            return ErrCode.E3000;
        }
        type = Utils.formatStr(type.toLowerCase());
        if (!JSON.equals(type) && !XML.equals(type)) {
            return ErrCode.E3001;
        }
        IGlobalOperator globalOperator = (IGlobalOperator) SpringUtils.getBean(type + "GlobalOperator");
        return globalOperator.operator(msg, request);
    }
}
